<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('统计销售报表列表')" />

</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>月份：</label>
                                <input type="text" id="dateMonth" placeholder="选择月份" name="dateMonth" class="layui-input">
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm hidden" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="statistics:statisticsSell:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="statistics:statisticsSell:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="statistics:statisticsSell:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="statistics:statisticsSell:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('statistics:statisticsSell:edit')}]];
        var removeFlag = [[${@permission.hasPermi('statistics:statisticsSell:remove')}]];
        let sell=[[${sell}]]
        var prefix = ctx + "statistics/statisticsSell";

        $(function() {
            var options = {
                url: prefix + "/list?remark="+sell.remark,
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "统计销售报表",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'statisticsSellId',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'contractId',
                    title: '合同id',
                    visible: false,
                },
                {
                    field: 'dateMonth',
                    title: '月份',
                    formatter:function (value, row, index){
                        return value.substring(0,7)
                    }
                },
                {
                    field: 'sellTotalMoney',
                    title: '销售金额',
                    visible: false,
                },
                {
                    field: 'sellStoreTotalMoney',
                    title: '出库金额'
                },
                {
                    field: 'profitTotalMoney',
                    title: '利润'
                },
                {
                    field: 'incomeTotalMoney',
                    title: '收入金额'
                },
                {
                    field: 'accountTotalMoney',
                    title: '对账金额'
                },
                {
                    field: 'remark',
                    title: '备注',
                    visible: false,
                },
                {
                    title: '操作',
                    align: 'center',
                    visible: false,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.statisticsSellId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.statisticsSellId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        //月份
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            // 初始化月份选择器
            laydate.render({
                elem: '#dateMonth', // 指定元素
                type: 'month', // 设置类型为月份选择
                format: 'yyyy-MM', // 设置返回的日期格式
                done: function(value, date){

                    // 选择结束后的回调函数
                    //console.log(value); // 打印选择的月份值
                    return value;
                }
            });
        });

    </script>
</body>
</html>
